Home | Printable Version
3.5: Web Service Proxy Configuration
WebMaker uses the Apache HttpClient module version 4.2.3 to handle the low-level calls to remote web services. WebMaker supports some additional settings to provide more advanced control over the external web service calls. These settings are split into two types: additional settings on the xgate HttpHeader fragment, and lower level HttpClient settings via a configuration file. Advanced HttpHeader Settings
The following additional attributes can be supplied on the root element (xg:HttpHeader) of the HttpHeader fragment used to perform REST calls:
output_response_headers - By default, when the Advanced Features are enabled for a proxy controller, information about the HTTP response headers will be included automatically in the response message returned to the controller. If the response message already defines a SOAP message, then these headers will be included in an HttpHeader block within the SOAP Header element of the response. If the response was not a SOAP message, then a SOAP wrapper will be created, with the response content in the Body, and the response headers available in the SOAP Header. If you are not interested in accessing the response headers, then this can cause additional work to remove this extra wrapper. Instead you should add an output_response_headers="false" attribute to the HttpHeader element. If this is present (with a value of 'false') then WebMaker will not attempt to return the response header information, and will not add SOAP wrappers to non-SOAP responses. maintain_context - If this attribute is provided and set to true then WebMaker will store the HttpClient HttpContext object for each user session. If the same user makes another call via the same web service proxy controller then this context will be reused. These context objects store state information, and reusing them can provide a performance improvement, especially when dealing with authenticated services. The HttpContext objects are stored in the user's session cache and should be listed in the platform status report available at http://<server>:<port>/<application>/get_xplatform_info.do. maintain_cookies - If maintain_context is set to true then this additional attribute can also be provided. If this is set to true then the HttpContext object will also store details of any cookies set by the remote service. On any subsequent calls to this service these cookie values will be sent automatically within the outgoing request. This can be useful for example when calling a service that requires an initial logon process, but then issues a session token cookie that should be used for all future requests. this could always be handled manually by setting the appropriate xgate HttpHeader attributes, but this provides a much simpler option.
HttpClient Configuration
In order to configure the underlying HttpClient instance you can provide an additional config file for each web service proxy. This allows configuration of lower level settings such as the number of connections to keep in the pool, what timeout values to use, what User Agent string to send to the remote service etc. This configuration file should be an XML file split into three sections as shown below
<httpclient_config>
    <connection_manager>
        <max_total_connections>50</max_total_connections>
        <max_connections_per_host>10</max_connections_per_host>
    </connection_manager>
    <client>
        <property name="http.socket.timeout" value="10000" type="java.lang.Integer"/>
        <property name="http.connection.timeout" value="10000" type="java.lang.Integer"/>
        ...
    </client>
    <request>
        <property name="http.useragent" value="New User Agent String" type="java.lang.String"/>
        ...
    </request>
</httpclient_config>
                    
You should save this file into the Other Resources category within the repository for your project with a name ending in httpclient_config.xml. For example, myproxy_httpclient_config.xml. This allows different configuration files to be used for different proxy controllers if required. You then need to use the Resource Details screen for the proxy controller to add this configuration file as a resource of this controller. To do this, use menu item Project | Advanced Project Settings...You can then locate your controller and click-through to reveal the navigation pattern diagram. At this stage, you can double-click the graphical controller icon. On the next screen, select the View Node Details radio option for the Double Click Action field and then double click the controller on the diagram. On the next screen you can click the View Engine & Resource Details. Finally, you should be able to use the Add Resource link on the next page to add your resource file and press Save. Both the client and request sections can contain any number of property elements. Properties set under the client section will be applied to the HttpClient object, whereas those listed under the request section will be applied to each HttpRequest object. For more details on the available settings please refer to the HttpClient tutorial documentation, for example Connection parameters and HTTP request execution parameters. This configuration file supports properties with types of java.lang.Integer, java.lang.String, and java.lang.Boolean. In addition, you can use a type of java.util.Collection when providing a comma separated list of strings within the value attribute for properties that require a String collection.
Remote Service Security RDBMS access using SQL